package it.koutifaris.travianmap.dal.sqlservices.travianserver;

import it.koutifaris.travianmap.dal.TravianServerSettingsService.TravianServerSettings;

class TravianServerSettingsImpl implements TravianServerSettings {

	private final String server;
	private final boolean autoUpdate;
	private final boolean wifiOnly;

	TravianServerSettingsImpl(String server, boolean autoUpdate, boolean wifiOnly) {
		this.server = server;
		this.autoUpdate = autoUpdate;
		this.wifiOnly = wifiOnly;
	}

	@Override
	public String getServer() {
		return server;
	}

	@Override
	public boolean isAutoUpdate() {
		return autoUpdate;
	}

	@Override
	public boolean isWifiOnly() {
		return wifiOnly;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (autoUpdate ? 1231 : 1237);
		result = prime * result + ((server == null) ? 0 : server.hashCode());
		result = prime * result + (wifiOnly ? 1231 : 1237);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof TravianServerSettingsImpl))
			return false;
		TravianServerSettingsImpl other = (TravianServerSettingsImpl) obj;
		if (autoUpdate != other.autoUpdate)
			return false;
		if (server == null) {
			if (other.server != null)
				return false;
		} else if (!server.equals(other.server))
			return false;
		if (wifiOnly != other.wifiOnly)
			return false;
		return true;
	}

}
